package net.huashitong.order.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.goodsclass.entity.GoodsClasses;
import net.huashitong.goodsclass.filter.GoodsClassFilter;
import net.huashitong.order.entity.Order;
import net.huashitong.order.filter.OrderFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class OrderDao extends StringDao<Order> {

    public List<Order> query(OrderFilter filter)
    {
        GenericQuery query = createQuery("obj");
        if (StringUtils.isNotBlank(filter.getGoodName())) {
            query.append(" and obj.goodName like :goodName");
            query.setParam("goodName", StringUtils.getLikewords(filter.getGoodName()));
        }
        if(StringUtils.isNotBlank(filter.getUserId()))
        {
            query.append("and obj.userId = :userId");
            query.setParam("userId",filter.getUserId());
        }
        return query.listResult(filter);

    }
}
